<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Service\Group;

use App\Models\GroupOrderProduct;
use App\Service\BaseService;

class GroupProductService extends BaseService
{
    public function addInventory($id, $number = 1)
    {
        GroupOrderProduct::query()->where('id', $id)->increment('stock', $number);
    }

    public function reduceInventory($id, $number = 1)
    {
        $gp = GroupOrderProduct::query()->findOrFail($id);
        if ($gp->checkTheStock($number)) {
            return false;
        }
        $gp->decrement('stock', $number);
    }
}
